package cn.jbolt.ai.app.controller;

import cn.jbolt.ai.app.entity.AiAppSession;
import cn.jbolt.ai.app.service.AiAppSessionService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 聊天会话controller
 */
@Controller
@ResponseBody
@RequestMapping("/aiAppSession")
@Tag(name = "APP会话controller")
public class AiAppSessionController {

    @Autowired
    private AiAppSessionService aiAppSessionService;


    @Operation(summary = "分页获取会话列表")
    @GetMapping("/getListByPage")
    public Result listByPage(@RequestParam(required = false)Long startId, Integer pageSize, @RequestParam(required = false) String keywords,
                             @RequestParam(required = false) Long appId) {

        return aiAppSessionService.listByPage(startId, pageSize,keywords, appId);
    }


    @Operation(summary = "添加会话")
    @PostMapping("/add")
    public Result add(@RequestBody AiAppSession aiSession) {
        return aiAppSessionService.add(aiSession);
    }

    @Operation(summary = "更新会话")
    @PostMapping("/update")
    public Result update(@RequestBody AiAppSession aiSession) {
        return aiAppSessionService.update(aiSession);
    }

    @Operation(summary = "删除会话")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        return aiAppSessionService.delete(id);
    }

    @Operation(summary = "根据ID获取会话")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return aiAppSessionService.getSession(id);
    }

}
